<?php
/* The Content */

global $options;
foreach ($options as $value) {
	if (isset($value['id']) && isset ($value['std']))
	if (get_option( $value['id'] ) === FALSE) {
		$$value['id'] = $value['std']; 
		} else {
		$$value['id'] = get_option( $value['id'] );
	}
}

if ( !have_posts() ) : ?>
    <div id="post-0" <?php //post_class('no-results not-found'); ?> class="no-results not-found" >
        <h2><?php _e( 'Not Found', 'misa' ); ?></h2>
        <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'misa' ); ?></p>
        <?php get_search_form(); ?>
    </div>
<?php endif;

while ( have_posts() ) : the_post(); 
	$post_opts = get_post_meta( $post->ID, 'post_options', true );
	$bloginfo = get_template_directory_uri();
	$thumbnail = $post_opts['thumb'];					
	$default_thumb = $bloginfo.'/images/post_thumb.png';
	$thumbnail = ( $thumbnail == '' ) ? $default_thumb : $thumbnail;

?>
        <div id="post-<?php the_ID();?>" <?php post_class('entry clearfix'); ?> >
            <div class="entry-header">           
            <?php if ( is_sticky() ) : ?>
				<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s', 'misa' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
				<h3 class="featured-post"><?php _e( 'Featured', 'misa' ); ?></h3>            
            <?php else : ?>            
            	<h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s', 'misa' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
			<?php endif; //end sticky?>                        
            	<?php if(!is_search()) { // Hide post meta for search pages ?>
                <div class="entry-meta"><?php misa_attachment_meta(); ?></div>              
			</div><!-- .entry-header -->           
            <div class="entry-content">
				<div class="blog-post foldify">
					<?php if ( $thumbnail ) { ?>
                    <a rel="prettyPhoto[image]" href="<?php echo $thumbnail; ?>">
                    	<img src="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php echo $thumbnail; ?>&amp;w=210&amp;h=150&amp;zc=1&amp;q=100" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/>
					</a>
					<?php } ?>
				</div><!-- .thumb_post -->
			<?php the_content( __( 'Read More &rarr;', 'misa' ), 'false' );
                wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'misa' ), 'after' => '</div>' ) );
            } // Not Search
            elseif( is_search() ) { // Only show excerpts for search results
				the_excerpt();
            } ?>
            </div><!-- .entry-content -->
        </div><!-- .entry -->
    <?php comments_template( '', true );
endwhile; // End the loop?>

	<?php if ( $wp_query->max_num_pages > 1 ) :?>
		<?php if ( function_exists( 'wp_pagenavi' ) ) wp_pagenavi();
    	else { ?>		
        	<div class="prev"><?php next_posts_link( __( '&larr; Older Posts', 'misa' ) ) ?></div>
        	<div class="next"><?php previous_posts_link( __( 'Newer Posts &rarr;', 'misa' ) ) ?></div>			
    	<?php }   
	endif; ?>
